package org.hzandyy.framework.liteflow.flow;

import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.core.NodeWhileComponent;
import lombok.extern.slf4j.Slf4j;

/**
 * @author Hu Zhi
 * @since 2023/12/7 16:57
 */
@LiteflowComponent("node_while")
@Slf4j
public class NodeWhileCmp extends NodeWhileComponent {

    private int num = 0;
    private int i = 0;

    @Override
    public boolean processWhile() throws Exception {
        if (i == 0) {
            num = 5;
        }

        boolean result = i < num;
        if (result) {
            log.info("loop while [{} / {}]", i, num);
        }

        i++;

        if (!result) {
            num = 0;
            i = 0;
        }

        return result;
    }

}
